package com.boil.qz.safekavass.web.sitemesh;

import org.sitemesh.SiteMeshContext;
import org.sitemesh.content.ContentProperty;
import org.sitemesh.content.tagrules.TagRuleBundle;
import org.sitemesh.content.tagrules.html.ExportTagToContentRule;
import org.sitemesh.tagprocessor.State;

/**
 * Created by ChenYong on 2016-09-21.
 * <br>
 * SiteMesh 自定义标签。
 */
public class CustomTagRuleBundle implements TagRuleBundle {
    /**
     * 如果需要添加多个自定义标签，直接 state.addRule() 多次即可。
     */
    @Override
    public void install(State state, ContentProperty contentProperty, SiteMeshContext siteMeshContext) {
        state.addRule("smLink1", new ExportTagToContentRule(siteMeshContext, contentProperty.getChild("smLink1"), false));
        state.addRule("smLink2", new ExportTagToContentRule(siteMeshContext, contentProperty.getChild("smLink2"), false));
        state.addRule("smScript1", new ExportTagToContentRule(siteMeshContext, contentProperty.getChild("smScript1"), false));
        state.addRule("smScript2", new ExportTagToContentRule(siteMeshContext, contentProperty.getChild("smScript2"), false));
        state.addRule("smModal", new ExportTagToContentRule(siteMeshContext, contentProperty.getChild("smModal"), false));
    }

    @Override
    public void cleanUp(State state, ContentProperty contentProperty, SiteMeshContext siteMeshContext) {

    }
}